package dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import pojo.Obtain;
import pojo.Page;

public interface ObtainDao {


	//查看用户是否已经获得下载权限
	@Select(value="select * from obtain where user_id=#{userId} and essay_id=#{essayId}")
	@Results({
			@Result(column="obtain_id",property="obtainId",id = true),
			@Result(column="user_id",property="userId"),
			@Result(column="essay_id",property="essayId")
	})
	public Obtain selectByUE(@Param("userId")Integer userId,@Param("essayId")Integer essayId);

	//根据用户查询文章id
	@Select(value="select essay_id from obtain where user_id=#{userId} limit #{page.currentPage},#{page.limitNumber}")
	@Results({
			@Result(column="essay_id",property="essayId")
	})
	public List<Integer> selectEssayByUser(@Param("userId") Integer userId, @Param("page") Page page);

	//根据用户查询文章id数量
	@Select(value="select count(*) from obtain where user_id=#{userId} ")
	public Integer selectEssayByUserCount(@Param("userId") Integer userId);
}
